<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/setting.css" />
</head>
<body class="gray">
	<div class="mui-content mui-clearfix">
	    <div class="mui-content-padded loading mui-clearfix" id="vueMain">
	    		<div class="mui-pull-left issue">
	    			<div class="issue-box">
		    			<div class="title">您的订单{{list.order.order_status_name}}，你是否想资讯以下问题：</div>
		    			<div class="list">
		    				<template v-for="(item,index) in list.list">
		    					<p :data-id="item.id" :data-idx="index">·{{item.title}}？</p>
		    				</template>
		    			</div>
	    			</div>
	    			<p>{{times}}</p>
	    		</div>
	    		<template v-for="item in handle">
	    			<div  v-bind:class="item.res?'mui-pull-right issueok':'mui-pull-left issueRes'">
		    			<div v-html="item.content"></div>
		    			<p>{{item.time}}</p>
		    		</div>
	    		</template>
	    </div>
	</div>
<script src="../js/mui.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps, views, user;
	mui.init({
		swipeBack:true,
		beforeback:function(){
			if( views.opener().id == 'server' ){
				bexta.setStatus(true);
			}
		}
	});
	mui.plusReady(function () {
	   user = bexta.getStorage(USER);
	   views = bexta.getWebview();
	   bexta.ajax(api.order_consult, function(res){
	   		initVue(res);
	   }, {data:{uid:user.uid, order_no:views.order_no}});
	});
	function initVue(res){
		apps = new Vue({
			el:"#vueMain",
			data:{
				list:res,
				times:bexta.getDateTime(),
				status:views.order_status, //订单状态,
				handle:[] //提问列表,
			},
			mounted:function(){
				document.querySelector('.loading').classList.add('loadRun');
				var self = this;
				mui('#vueMain').on('tap', '.list p', function(){
					var idx = this.getAttribute('data-idx');
					self.handle.push({
						res:true,
						id:self.list.list[idx].id,
						content:self.list.list[idx].title,
						time:bexta.getDateTime()
					});
					bexta.ajax(api.issue_detail, function(res){
						if( res ){
							self.handle.push({
								res:false,
								id:res.id,
								content:res.content || "我也不知道",
								time:bexta.getDateTime()
							});
						}else{
							self.handle.push({
								res:false,
								id:1,
								content:"不要问我为什么，反正我也不知道，不管你信不信，反正我自已相信",
								time:bexta.getDateTime()
							});
						}
						
						var c = document.querySelector('.mui-content');
						mui.scrollTo(c.scrollHeight,10);
					},{data:{issue_id:apps.list.list[idx].id}});
				});
			}
		});
	}
	
</script>
</body>
</html>